import {BasicColumn, FormSchema} from '@/components/table';
import {render} from '@/hooks/render/renderUtils';
import {Api} from './message.api';
import {RenderType} from '@pkg/setting';

export const columns: BasicColumn[] = [
  {
    title: '消息标题',
    dataIndex: 'msgTitle',
    width: 120,
  },
  {
    title: '封面图',
    dataIndex: 'msgImage',
    width: 60,
    customRender: render.renderImage,
  },
  {
    title: '消息类型',
    dataIndex: 'typeName',
    width: 120,
  },
  {
    title: '消息状态',
    dataIndex: 'readState',
    width: 120,
    dictData: [
      {label: '已读', value: 1},
      {label: '未读', value: 0}
    ],
    renderType: RenderType.DICT
  },
  {
    title: '发送时间',
    dataIndex: 'sendTime',
    width: 120,
  }
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '消息标题',
    field: 'msgTitle',
    component: 'Input',
    colProps: {span: 5},
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '消息类型',
    field: 'msgTypeId',
    component: 'ApiSelect',
    required: true,
    componentProps: {
      api: Api.messageTypeList,
      labelField: 'typeName',
      valueField: 'msgTypeId',
      immediate: true,
    },
  },
  {
    label: '消息标题',
    field: 'msgTitle',
    component: 'Input',
    required: true,
  },
  {
    label: '消息内容',
    field: 'msgContent',
    component: 'TyEditor',
    required: true,
  },
  {
    label: '摘要',
    field: 'msgSummary',
    component: 'InputTextArea',
  },
  {
    label: '封面图',
    field: 'msgImage',
    component: 'ImageUpload',
  },
];
